package homework12月8号.homework1.h1;

import java.io.FileWriter;
import java.lang.reflect.Constructor;
import java.util.Properties;

/*/*
 * 1、
 * Person代码不可以更改！！！
 * 创建一个Person对象，
 * 保存如下数据到对象中：
 * 小张，18,  130302201110010001
 *
 * 调用Person对象的toString()方法在控制台展示数据
 *
 * 2、
 * 将Person对象的数据保存到data2.properties文件中（字段顺序无序即可）
 * name=小张
 * age=18
 * idCardNum=130302201110010001
 */
public class Demo2 {
	public static void main(String[] args) throws Exception{
		Class<?> aClass = Class.forName("czxy.homework.h1.Person");
		Constructor<?> c = aClass.getDeclaredConstructor(String.class,int.class,String.class);
		c.setAccessible(true);
		Object s = c.newInstance("小张", 18, "130302201110010001");
		String string = s.toString();
		System.out.println(string);



		Properties pro = new Properties();
		pro.setProperty("name","小张");
		pro.setProperty("age","18");
		pro.setProperty("idCardNum","130302201110010001");
		FileWriter out = new FileWriter("data2.properties");
		pro.store(out,"123");
		out.close();
	}

}
